package org.hackystat.ambientdevice.device.bunny;

import java.util.logging.Logger;
import org.hackystat.ambientdevice.device.AmbientAction;

/**
 * Implements the Text-To-Speech feature of the Nabaztag for the AmbientHackystat
 * system by saying what is found in the configuration file.
 * 
 * @author Sonwright M. Gomez
 *
 */
public class TextToSpeech implements AmbientAction {

  /** the Nabaztag that will change its TextToSpeech. */
  private Nabaztag nabaztag;
  /** String containing the text to be synthesized to speech. */
  private String textToSpeech;
  private Logger logger = Logger.getLogger("org.hackystat.ambientdevice");
  
  /**
   * The method that makes the bunny talk.
   * 
   * @param nabaztag the nabaztag to set
   * @param textToSpeech the string that you want it to say
   */
  public TextToSpeech (Nabaztag nabaztag, String textToSpeech) {
    this.nabaztag = nabaztag;
    try {
      this.textToSpeech = textToSpeech;
    }
    catch (java.lang.IllegalArgumentException e) {
      logger.warning("Text " + textToSpeech + " is not supported.");
    }
  }
  
  /**
   * makes the bunny talk.
   */
  public void act() {
    logger.info("Change TextToSpeech parameter to " + "\"" + this.textToSpeech
        + "\"");
    nabaztag.setTextToSpeech(this.textToSpeech);
    nabaztag.updateTextToSpeechState();
    
  }

  /**
   * @param nabaztag the nabaztag to set
   */
  public void setNabaztag(Nabaztag nabaztag) {
    this.nabaztag = nabaztag;
  }

  /**
   * @return the nabaztag
   */
  public Nabaztag getNabaztag() {
    return nabaztag;
  }

  /**
   * @param textToSpeech the textToSpeech to set
   */
  public void setTextToSpeech(String textToSpeech) {
    this.textToSpeech = textToSpeech;
  }

  /**
   * @return the textToSpeech
   */
  public String getTextToSpeech() {
    return textToSpeech;
  }
  
}
